package com.changgou.order.feign;

import com.changgou.entity.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 购物车feign接口
 */
@FeignClient(name = "order")
@RequestMapping("/cart")
public interface CartFeign {

    /**
     * 添加商品到购物车接口
     * @param skuId 添加商品的库存id
     * @param num   购买数量
     * @return
     */
    @GetMapping("/add/{skuId}/{num}")
    public Result add(@PathVariable(value = "skuId") String skuId, @PathVariable(value = "num")Integer num);


    /**
     * 查询购物车列表
     * @return
     */
    @GetMapping("/list")
    public Map<String, Object> list();

    /**
     * 删除
     * @param skuId
     * @return
     */
    @GetMapping("/delete")
    public Result delete(@RequestParam(value = "skuId") String skuId);

    /**
     * 购物车列表复选框状态, 勾选与取消勾选
     * @param skuId     勾选商品的库存id
     * @param checked   勾选与取消勾选状态
     * @return
     */
    @GetMapping("/updateChecked")
    public Result updateChecked(@RequestParam(value = "skuId") String skuId,
                                @RequestParam(value = "checked")Boolean checked);
}
